﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;

namespace SecurityDev
{
    public partial class Users : Form
    {
        OutpostDS.usersDataTable userDT;
        OutpostDSTableAdapters.usersTableAdapter userAdapter;

        public Users()
        {
            InitializeComponent();            
        }
        
        private void Users_Load(object sender, EventArgs e)
        {
            userAdapter = new OutpostDSTableAdapters.usersTableAdapter();
            try
            {
                userDT = userAdapter.GetData();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }            
            dataGridView1.DataSource = userDT;            

            dataGridView1.Columns["IdUse"].HeaderText = "User ID";
            dataGridView1.Columns["UserName"].HeaderText = "Name";
            dataGridView1.Columns["UserPass"].HeaderText = "Password";
            dataGridView1.Columns["IsAdmin"].HeaderText = "Is admin";
        }

        private void DoneBtn_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void SaveChBtn_Click(object sender, EventArgs e)
        {
            try
            {
                userAdapter.Update(userDT);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }  
            
        }
    }
}
